Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate pyzag bindings for neml2 #178

Merged
merged 38 commits into from
Dec 11, 2024
Merged

Conversation

reverendbedford
Copy link
Collaborator

Add pyzag wrappers for NEML2 model and include some basic tests.

This will make pyzag a dependency of NEML2.

Copy link
Contributor

github-actions bot commented Dec 10, 2024

Test Results (ubuntu-latest-Debug-ON)

    3 files  ±0      3 suites  ±0   1m 33s ⏱️ -1s
  537 tests +2    537 ✅ +3  0 💤 ±0  0 ❌ ±0 
3 176 runs  +2  3 176 ✅ +3  0 💤 ±0  0 ❌ ±0 

Results for commit 394b3c6. ± Comparison against base commit 53b7035.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Dec 10, 2024

Documentation preview removed.
To view the documentation, please visit the main documentation page.

Copy link
Contributor

github-actions bot commented Dec 10, 2024

Test Results (macos-latest-Debug-OFF)

    3 files  ±0      3 suites  ±0   41s ⏱️ -1s
  537 tests +2    537 ✅ +3  0 💤 ±0  0 ❌ ±0 
3 176 runs  +2  3 176 ✅ +3  0 💤 ±0  0 ❌ ±0 

Results for commit 394b3c6. ± Comparison against base commit 53b7035.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Dec 10, 2024

Test Results (macos-latest-Release-OFF)

    3 files  ±0      3 suites  ±0   18s ⏱️ ±0s
  537 tests +2    537 ✅ +3  0 💤 ±0  0 ❌ ±0 
3 174 runs  +2  3 174 ✅ +3  0 💤 ±0  0 ❌ ±0 

Results for commit 394b3c6. ± Comparison against base commit 53b7035.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Dec 10, 2024

Test Results (ubuntu-latest-Release-OFF)

    3 files  ±0      3 suites  ±0   37s ⏱️ +2s
  537 tests +2    537 ✅ +3  0 💤 ±0  0 ❌ ±0 
3 174 runs  +2  3 174 ✅ +3  0 💤 ±0  0 ❌ ±0 

Results for commit 394b3c6. ± Comparison against base commit 53b7035.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@hugary1995 hugary1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes on the c++ side look okay to me. A few minor comments.

Now onto the python part...

src/neml2/models/LinearInterpolation.cxx Show resolved Hide resolved
src/neml2/models/Model.cxx Outdated Show resolved Hide resolved
src/neml2/models/Model.cxx Outdated Show resolved Hide resolved
src/neml2/models/Model.cxx Outdated Show resolved Hide resolved
src/neml2/models/Model.cxx Outdated Show resolved Hide resolved
src/neml2/models/Model.cxx Outdated Show resolved Hide resolved
src/neml2/models/Model.cxx Outdated Show resolved Hide resolved
src/neml2/models/SmoothLinearInterpolation.cxx Outdated Show resolved Hide resolved
Copy link
Collaborator

@hugary1995 hugary1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's all my comments.

python/neml2/pyzag/interface.py Show resolved Hide resolved
python/neml2/pyzag/interface.py Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Dec 11, 2024

Test Results (ubuntu-latest-Debug-OFF)

    3 files  ±0      3 suites  ±0   1m 35s ⏱️ +5s
  537 tests +2    537 ✅ +3  0 💤 ±0  0 ❌ ±0 
3 176 runs  +2  3 176 ✅ +3  0 💤 ±0  0 ❌ ±0 

Results for commit 394b3c6. ± Comparison against base commit 53b7035.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Dec 11, 2024

Python Binding Test Results (macos-latest)

94 tests  +18   70 ✅ +18   8s ⏱️ +7s
 1 suites ± 0   24 💤 ± 0 
 1 files   ± 0    0 ❌ ± 0 

Results for commit 394b3c6. ± Comparison against base commit 53b7035.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Dec 11, 2024

Python Binding Test Results (ubuntu-latest)

94 tests  +18   70 ✅ +18   11s ⏱️ +10s
 1 suites ± 0   24 💤 ± 0 
 1 files   ± 0    0 ❌ ± 0 

Results for commit 394b3c6. ± Comparison against base commit 53b7035.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@hugary1995 hugary1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are running out of independent reviewers, so I'll just merge when all tests pass.

@hugary1995
Copy link
Collaborator

Urgh the clang-tidy check is unbearably slow. We need to fix it...

@reverendbedford
Copy link
Collaborator Author

Don't merge yet, I haven't rerun the stochastic example to make sure I got all the changing things.

Copy link
Collaborator

@hugary1995 hugary1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not add nbdime, pyro, and tqdm as a global dependency, as they bring in a fair number of packages.

requirements.txt Outdated Show resolved Hide resolved
python/examples/README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@hugary1995 hugary1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My final comment:

I think torch.manual_seed doesn't guarantee reproducibility in different environments. The SVI example has two stochastic aspects: training and inference. If you save the checkpoint and reload it in the notebook, the trained model should be reproducible. But then IDK how to make the inference part (i.e., sampling the posterior) truly reproducible.

@reverendbedford
Copy link
Collaborator Author

My final comment:

I think torch.manual_seed doesn't guarantee reproducibility in different environments. The SVI example has two stochastic aspects: training and inference. If you save the checkpoint and reload it in the notebook, the trained model should be reproducible. But then IDK how to make the inference part (i.e., sampling the posterior) truly reproducible.

Actually I think the SVI examples in pyzag are fully-reproducible by setting the random seed in torch. But we'll see in a minute.

@reverendbedford reverendbedford merged commit 19b1563 into main Dec 11, 2024
34 checks passed
@reverendbedford reverendbedford deleted the pyzag_integration_v2 branch December 11, 2024 16:34
github-actions bot added a commit that referenced this pull request Dec 11, 2024
hugary1995 added a commit that referenced this pull request Dec 14, 2024
Setup an interface to evaluate and train NEML2 models in pyzag.  This also makes pyzag a dependency of this package.  Includes a few examples and tests.

---------

Co-authored-by: Gary Hu <[email protected]>
hugary1995 added a commit that referenced this pull request Dec 14, 2024
Setup an interface to evaluate and train NEML2 models in pyzag.  This also makes pyzag a dependency of this package.  Includes a few examples and tests.

---------

Co-authored-by: Gary Hu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants